<?php
/**
 * View Nuovo Live LaFabbrica.org
 * 
 * @author     luigi.pastore (gigi@la-fabbrica.org)
 * @created    17-mag-2011
 * @package    LaFabbrica
 * @copyright  Copyright (c) 2011 Luigi Pastore
 */
?>
<script type="text/javascript">
    //<![CDATA[
     
    function selectable(){
	$('a[id^="add-artist"]').click(function(){
	    var id = $(this).attr('id');
            $('#selected_artists').load('/admin/ajax/select/addliveartist/id/'+id.substr(11,id.length),
            unselectable // CallBack
	)})
    };

    function unselectable(){
        $('a[id^="unlink-artist"]').click(function(){
            var id = $(this).attr('id');
            $('#selected_artists').load('/admin/ajax/select/remliveartist/id/'+id.substr(14,id.length),
            unselectable // CallBack
        );
	})};
     
    $(document).ready(function()
    {
        var paginator =	$('#artists').pagination({
                'targetUrl' : '/admin/ajax/list/artistsmini',
                'orderField' : 'artist_name',
                'orderDir' : 'asc'
            },selectable // CallBack
        );

	$("#new").fancybox({
	    'type' : 'ajax',
	    'showCloseButton' : false
	});
        
        $("#salva").click(function() {
	    $('#form-invia').submit();
	    //          return false;
        });
	
	// Lancio unselectable per i contatti eventualmente già presenti...
	unselectable();
        
        $( "#searchField" ).keyup( function() {
            if($(this).val().length >= 3)
            {
                var pagination = $('#artists').pagination({
                    'targetUrl' : '/admin/search/artistsmini/'+ $(this).val(),
                    'orderField' : 'artist_name',
                    'orderDir' : 'asc'
                }, selectable);
            }
            else if($(this).val().length == 0)
            {
                var pagination = $('#artists').pagination({
                    'targetUrl' : '/admin/ajax/list/artistsmini',
                    'orderField' : 'artist_name',
                    'orderDir' : 'asc'
                }, selectable);                
            }
        });        
    });

    //]]>
</script>
<div id="content">
    <form>

	<div id="summary" class="live">
	    <div class="head">
		<h2>Live:</h2>
	    </div>
	    <div class="body">&nbsp;</div>
	</div>
	<ul id="paging-live">
	    <li class="paging-context ">
		<table class="pgStyle1 circle2" cellspacing="0">
		    <tr>
			<td class="c selected">
			    <var>1</var>
			</td>
			<td class="t selected">
			    <b id="pagecircle1">Artisti</b>
			</td>
			<td class="c ">
			    <var>2</var>
			</td>
			<td class="t">
			    <b id="pagecircle2">Location</b>
			</td>
			<td class="c ">
			    <var>3</var>
			</td>
			<td class="t">
			    <b id="pagecircle2">Dettagli Live</b>
			</td>
			<td class="c">
			    <var>3</var>
			</td>
			<td class="t">
			    <b id="pagecircle2">Conferma</b>
			</td>			    
		    </tr>
		</table>
	    </li>
	</ul>
	<div class="help">
	    <h2>Artisti</h2>
	    <br/>Seleziona gli artisti del live dall'elenco a sinistra.
	    <div>I campi contrassegnati da <span class="req">*</span> sono obbligatori!</div>
	</div>
	<ul>
	    <li id="errorLi" style="<?php echo $this->errorMsg ? '' : 'display:none' ?>">
		<h3 id="errorMsgLbl">Si &egrave; verificato un problema durante l'invio del modulo.</h3>
		<p id="errorMsg">
		    <?php echo $this->errorMsg ?>
		</p>
	    </li>	
	    <li class="section"><h3></h3></li>
	</ul>
    </form>
    <div id="detailTableLeft">
	<form>
	    <ul>
		<li id="fo2li107" class="likert col2">
                    <table cellspacing="0">
                        <caption id="title107">
                            <div class="searchBox">
                                <label class="search">Cerca</label>
                                <input class="search" id="searchField" class="text" type="search" value="">
                            </div>
                        </caption>
			<thead>
			    <tr>
				<td colspan="5" class="pagination">
				    <div class="paginator">
					<span class="prev">
					    <a href="javascript: void(0);">&nbsp;</a>
					</span>
					<span class="loader">Sto caricando...</span>
					<span class="next">
					    <a href="javascript: void(0);">&nbsp;</a>
					</span>
				    </div>
				</td>
			    </tr>		    
			    <tr>
				<th class="sortable default {ref: 'artist_name'}">Nome</th>
				<td>&nbsp;</td>
			    </tr>
			</thead>
			<tbody id="artists">
			    <!-- Questo contenuto verrà rimpiazzato dalla paginazione-->

			</tbody>
		    </table>
		</li>

	    </ul>
	</form>
    </div>	
    <div id="detailTableRight">
	<form id="form-invia" method="post" action="/admin/live/artisti/id/<?php echo $this->live_id ?>">
	    <ul>
		<li id="fo2li107" class="likert col2">
		    <table cellspacing="0">
			<thead>
			    <tr>
				<td colspan="5">&nbsp;</td>
			    </tr>		    
			</thead>		    
			<tbody id="selected_artists">
			    <!-- Questo contenuto verrà rimpiazzato dalla paginazione-->
			    <?php
			    if( count( $this->artists ) ):
				foreach( $this->artists['main'] AS $artist ) :
				    ?>
				    <tr class="unselectable" id="artist_<?php echo $artist['artist_id'] ?>">
					<th>
					    <span><?php echo $artist['artist_name'] ?></span>
					</th>
					<td>
					    <ul>
						<li class="complex">
						    <input type="hidden" name="artists[]" id="artists" value="<?php echo $artist['artist_id'] ?>" />
						    <input class="field checkbox" name="artist_<?php echo $artist['artist_id'] ?>" id="artist_<?php echo $artist['artist_id'] ?>" type="checkbox" value="openingact" />
						    <label class="choice" for="artist_<?php echo $artist['artist_id'] ?>">Opening Act</label>
						</li>		
					    </ul>
					</td>
					<td title="Operazioni">
					    <span class="actions">
						<a class="del" id="unlink-artist-<?php echo $artist['artist_id'] ?>" href="#">
						    &nbsp;
						</a>
					    </span>
					</td>
				    </tr>
				    <?php
				endforeach;
                            endif; ?>
			    <?php
			    if( count( $this->artists['openingact'] ) ):
				foreach( $this->artists['openingact'] AS $artist ) :
				    ?>
				    <tr class="unselectable" id="artist_<?php echo $artist['artist_id'] ?>">
					<th>
					    <span><?php echo $artist['artist_name'] ?></span>
					</th>
					<td>
					    <ul>
						<li class="complex">
						    <input type="hidden" name="artists[]" id="artists" value="<?php echo $artist['artist_id'] ?>" />
						    <input class="field checkbox" name="artist_<?php echo $artist['artist_id'] ?>" id="artist_<?php echo $artist['artist_id'] ?>" type="checkbox" value="openingact" checked="checked" />
						    <label class="choice" for="artist_<?php echo $artist['artist_id'] ?>">Opening Act</label>
						</li>		
					    </ul>
					</td>
					<td title="Operazioni">
					    <span class="actions">
						<a class="del" id="unlink-artist-<?php echo $artist['artist_id'] ?>" href="#">
						    &nbsp;
						</a>
					    </span>
					</td>
				    </tr>
				    <?php
				endforeach;
                            endif; ?>
			</tbody>
		    </table>		
		    <input type="hidden" name="conferma" id="conferma" value="conferma" />
		</li>
	    </ul>
	</form>
    </div>

    <br style="clear: both" />
    <form>
	<ul>
	    <li class="section">
		<h3>Oppure:</h3>
		<ul>
		    <li class="addnew">
			<a id="new" class="button" href="/admin/ajax/form/newartist">
			    <img src="/images/admin/add-new.png" />Aggiungi Nuovo Artista (Veloce)
			</a>
		    </li>
		</ul>
	    </li>
	</ul>
    </form>
</div>
<div id="formButtons">
    <button id="salva" name="salva" value="salva" class="button positive">
	<img src="/images/admin/tick.png" alt="" />Continua
    </button>
    <a id="annulla" name="annulla" value="annulla" class="button negative" href="#">
	<img src="/images/admin/cross.png" alt="" />Annulla
    </a>
</div>